package com.wsl.controller;

import com.wsl.entity.Address;
import com.wsl.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:WangShuliang
 * @Description:
 * @Date:Created in 11:03 2017/10/29
 * @Modified by:
 */
@RestController
public class DemoEndpoint {
    @Autowired
    DemoService demoService;
    @RequestMapping(value = "/test",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String putUser(){
        demoService.findUser(1L,"zhang","san");
        demoService.findAddress(2L,"jx","gz");
        System.out.println("if it not print '无缓存的时候调用'");
        return "ok";
    }
    @RequestMapping(value = "/test2",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String testCache(){
        String user = demoService.findUser(1L,"zhang","san");
        Address address= demoService.findAddress(2L,"jx","gz");
        System.out.println("it not excute query");
        //System.out.println("user:"+"/"+user.getFirstName());
        System.out.println("address"+"/"+address.getProvince());
        return "ok";
    }
}